init
命令允许你使用start.spring.io在不离开shell的情况下创建一个新的项目。例如:
$ spring init --dependencies=web,data-jpa my-project
Using service at https://start.spring.io
Project extracted to '/Users/developer/example/my-project'
这创建了一个my-project
目录,它是一个基本Maven且依赖spring-boot-starter-web
和spring-boot-starter-data-jpa
的项目。你可以使用--list
参数列出该服务的能力。
$ spring init --list
=======================================
Capabilities of https://start.spring.io
=======================================
Available dependencies:
-----------------------
actuator - Actuator: Production ready features to help you monitor and manage your application
...
web - Web: Support for full-stack web development, including Tomcat and spring-webmvc
websocket - Websocket: Support for WebSocket development
ws - WS: Support for Spring Web Services
Available project types:
------------------------
gradle-build - Gradle Config [format:build, build:gradle]
gradle-project - Gradle Project [format:project, build:gradle]
maven-build - Maven POM [format:build, build:maven]
maven-project - Maven Project [format:project, build:maven] (default)
...
init
命令支持很多选项,查看help
输出可以获得更多详情。例如,下面的命令创建一个使用Java8和war打包的gradle项目:
$ spring init --build=gradle --java-version=1.8 --dependencies=websocket --packaging=war sample-app.zip
Using service at https://start.spring.io
Content saved to 'sample-app.zip'